{extends file="../acp.html"}

{block name="title"}{$head_title}{/block}
{block name="content"}
<script>
    function no_pic(obj) {
        obj.setAttribute("src", "/Public/Images/acp/nopicture.jpg");
    }
</script>

<div class="tablesWrap">
    <div class="tables-searchbox">
        <form method="post">
            <span class="tbs-txt">关键字搜索：</span>
            <input type="text" name="key_words" value="{$key_words}">

            <!--  <span class="tbs-txt">{$ITEM_NAME}货号：</span>
              <input type="text" class="mini" name="item_sn" value="{$item_sn}">
  -->
            <!--
            <span class="tbs-txt">销售量：</span>
            <input type="text" style="width:60px;" name="start_sales_num" value="{$start_sales_num}">
            <span class="tbs-txt">——</span>
            <input type="text" style="width:60px;" name="end_sales_num" value="{$end_sales_num}">
            -->

            <!--<select name="activity_status" id="activity_status">
                <option value="-1"{if $activity_status==-1}selected{/if}>-活动状态-</option>
                &lt;!&ndash; <option value="0" {if $activity_status==0}selected{/if}>下架</option>&ndash;&gt;
                <option value="1" {if $activity_status==1}selected{/if}>预告期</option>
                <option value="2" {if $activity_status==2}selected{/if}>报名期</option>
                <option value="3" {if $activity_status==3}selected{/if}>活动期</option>
                <option value="4" {if $activity_status==4}selected{/if}>活动结束</option>
            </select>
            <select name="is_index" id="is_index" class="small">
                <option value="-1"{if $is_index==-1}selected{/if}>-是否首页显示-</option>
                <option value="0" {if $is_index==0}selected{/if}>否</option>
                <option value="1" {if $is_index==1}selected{/if}>是</option>
            </select>-->
     <!--       <span class="tbs-txt">活动开始时间：</span>
            <input type="text" autocomplete="off" class="Wdate" name="start_date" value="{$start_date|date_format:'%Y-%m-%d'}"  onclick="WdatePicker()">-->
            <!-- <span class="tbs-txt">添加时间：</span>
             <input type="text" autocomplete="off" class="Wdate" name="start_date" value="{$start_date|date_format:'%Y-%m-%d'}"  onclick="WdatePicker()">
             <span class="tbs-txt">至</span>
             <input type="text" autocomplete="off" class="Wdate" name="end_date" value="{$end_date|date_format:'%Y-%m-%d'}"  onclick="WdatePicker()">-->
            <input type="hidden" name="opt" value="select">
            <button type="submit" class="btn"><i class="gicon-search"></i>搜索</button>
            <!--        <button type="button" class="btn" style="background-color:#FF9900;color:#FFF" onclick="sync_item();">同步商品资料</button>-->


        </form>
    </div>
    <!-- end tables-searchbox -->
    <table class="wxtables">
        <colgroup>
            <!--  <col width="5%">
              <col width="5%">
              <col width="5%">
              <col width="10%">-->
       <!--     <col width="7%">
            <col width="7%">
            <col width="7%">
            <col width="7%">
            <col width="10%">-->
            <col width="7%">
            <col width="7%">
            <col width="7%">
            <col width="7%">
            <col width="10%">
            <col width="7%">
        </colgroup>
        <thead>
        <tr>
            <td>选择</td>
            <td>活动名</td>
           <!-- <td>图片</td>
            <td>活动状态</td>
            <td>开始时间</td>
            <td>主办方</td>
            <td>承办方</td>-->
            <td>评论人</td>
            <td>被评论人</td>
            <td>内容</td>
            <td>操作</td>
        </tr>
        </thead>
        <tbody>
        {foreach from=$comment_list  item=comment }
        <tr>
            <td><input type="checkbox" class="checkbox" value="{$comment.comment_id}" name="checkIds[]"></td>
            <td>{$comment.activity_title}</td>
            <td>{$comment.from_nickname}</td>
            <td>{$comment.to_nickname}</td>
            <td>{$comment.activity_comment}</td>
            <td>
        <!--        <a href="/AcpActivity/edit_activity/activity_id/{$activity.activity_id}" class="btn" title="编辑">编辑</a>
                <a href="/AcpActivity/get_comment_list/activity_id/{$activity.activity_id}" class="btn" title="查看评论">查看评论</a>-->

                <a  class="btn" title="删除" onclick="del_comment({$comment.comment_id})">删除</a>
            </td>
        </tr>
        {foreachelse}
        <tr><td colspan="10">没有找到任何记录</td></tr>
        {/foreach}
        </tbody>
    </table>
    <!-- end wxtables -->
    <div class="tables-btmctrl clearfix">
        <div class="fl">
            <a href="javascript:selall()" class="btn btn-blue">全选</a>
            <a href="javascript:clearall()" class="btn btn-blue">取消</a>
            <!--<a href="javascript:;" class="btn btn-blue J_batch_store">下架</a>-->
            <a href="javascript:;" class="btn btn-blue" onclick="delCommentBatch()">删除</a>
        </div>
        <div class="fr">
            <div class="paginate">
                {$page->show()}
            </div>
            <!-- end paginate -->
        </div>
    </div>
    <!-- end tables-btmctrl -->
</div>
<!-- end tablesWrap -->
{/block}

{block name="js"}
<script src="/Public/Plugins/My97DatePicker/WdatePicker.js?version={$version}"></script>
<script src="__ACPJS__/acp_item.js?version={$version}"></script>
<script src="__ACPJS__/AcpItem/list_item.js?version={$version}"></script>
<script src="__JS__/front/jquery.showLoading.min.js?version={$version}"></script>
<script src="__JS__/clipboard.min.js"></script>
<link rel="stylesheet" href="__CSS__/front/showLoading.css?version={$version}">
{literal}
<script>
    var item_name = '{$ITEM_NAME}';

    function sync_item()
    {
        var html = "确定执行此操作，本操作将比较费时，请耐心等候!";
        $.jPops.custom({
            title:"同步商品资料",
            content:html,
            okBtnTxt:"确定",
            cancelBtnTxt:"取消",
            callback:function(r)
            {
                if(r)
                {
                    $('body').showLoading();
                    $.post('/Global/sync',{},function(data) {
                        $("body").hideLoading();
                        if (data == 'success') {
                            alert('同步成功');
                            location.reload();
                        } else {
                            alert('同步失败，请稍后再试');
                        }
                    });
                }
                return true;
            }
        });
    }
    //复制商品链接
    function item_link(item_id, is_integral)
    {
        if(is_integral == 1){
            action = 'integral_item_detail';
        }else{
            action = 'item_detail';
        }
        var link = 'http://' + document.domain + '/FrontMall/'+action+'/item_id/' + item_id;
        $.jPops.custom({
            title:"请复制链接",
            content:'<div>商品链接：' + link + '</div>',
            okBtnTxt:"复制",
            cancelBtnTxt:"关闭",
            callback:function(r)
            {
                if(r)
                {
                    text = link;
                    copy_text('jpops-btn-ok');
                }
                else
                {
                    return true;
                }
            }
        });
    }
    function del_comment(comment_id){
        var html = "确定删除这个评论?";
        $.jPops.custom({
            title:"删除评论",
            content:html,
            okBtnTxt:"确定",
            cancelBtnTxt:"取消",
            callback:function(r)
            {
                console.log(r);
                if(r)
                {
                    $.post('/AcpActivity/del_comment',{'comment_id':comment_id},function(data) {
                        if (data == 'success') {
                            alert('删除成功');
                            location.reload();
                        } else {
                            alert('删除失败');
                        }
                    });
                }
                return true;
            }
        });
    }
    //批量删除
    function delCommentBatch(){
        var ids='';
        var count='';
        $('input[name="checkIds[]"]:checked').each(function()
        {
            count ++;
            ids += $(this).val() + ',';
        });
        console.log(ids);
        if(count== 0){
            $.jPops.alert({
                title:"提示",
                content:'对不起，请选择要删除项！',
                okBtnTxt:"确定",
                callback:function(){
                    return true;
                }
            });
            return false;
        }
        $.jPops.confirm({
            title:"提示",
            content:'您确定要删除这些数据吗？',
            okBtnTxt:"确定",
            cancelBtnTxt:"取消",
            callback:function(r){
                if(r){
                    $.ajax({
                        url: '/AcpActivity/del_comment_batch',
                        data: {id: ids},
                        type:'post',
                        success: function(data){
                            console.log(data)
                            if(data == 'success'){
                                $.jPops.alert({
                                    title:"提示",
                                    content:'删除成功',
                                    okBtnTxt:"确定",
                                    callback:function(){
                                        window.location.reload();
                                    }
                                });
                            }else{
                                $.jPops.alert({
                                    title:"提示",
                                    content:'删除失败',
                                    okBtnTxt:"确定",
                                    callback:function(){
                                        return true;
                                    }
                                });
                            }
                        }
                    });
                }
                return true;
            }
        });
    }
    function copy_text(id)
    {
        var clipboard = new Clipboard('#' + id, {
            text: function() {
                return text;
            }
        });

        clipboard.on('success', function(e) {
            console.log(e);
            alert('复制成功');
        });

        clipboard.on('error', function(e) {
            console.log(e);
            alert('复制失败，请手动复制');
        });
    }
</script>
{/literal}
{/block}
